package ioperation;

import Book.Book;
import Book.BookShelf;

import java.util.Scanner;

public class BorrowOperation implements IOperation{
    @Override
    public void work(BookShelf bookShelf) {
        System.out.println("#########借阅图书#########");
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入借阅图书书名：");
        String name=scanner.nextLine();
        int currentSize= bookShelf.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book=bookShelf.getBooks(i);

            if(book.getName().equals(name)){
                if(book.isBorrowed()==true){
                    System.out.println("已经借出去了");
                    return;
                }
               book.setBorrowed(true);
               System.out.println("借阅成功");
               return;
            }
        }
        System.out.println("找不到啊，没有你要的书呢亲亲！！！！！！！！！！");
    }
}
